#include "CAnnouncementsPanel.h"

std::vector<std::string> CAnnouncementsPanel::Announcements;
TCODConsole* CAnnouncementsPanel::Panel;
rect CAnnouncementsPanel::Area;

void CAnnouncementsPanel::addAnnouncement(std::string announcement)
{
	Announcements.push_back(announcement);
}

void CAnnouncementsPanel::cleanup()
{
	delete Panel;
}

void CAnnouncementsPanel::draw()
{
	Panel->clear();

	unsigned int i = 0;
	for (std::vector<std::string>::reverse_iterator it = Announcements.rbegin(); it != Announcements.rend(); ++it)
	{
		if (i < (unsigned)Area.height()-1)
		{
			Panel->print(3, Area.height()-1-i, (*it).c_str());
			i++;
		}
		else
            break;
	}

	TCODConsole::blit(Panel, 0, 0, Area.width(), Area.height(), TCODConsole::root, Area.upperLeft().x(), Area.upperLeft().y());
}

void CAnnouncementsPanel::init(rect area)
{
	Area = area;
	Panel = new TCODConsole(Area.width(), Area.height());

	Announcements.push_back("Game Started");
}
